package login.ui;

import java.awt.Color;
import java.awt.GridLayout;
import java.awt.event.ActionListener;

import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JPasswordField;
import javax.swing.JTextField;

public class LoginUI extends JPanel
{
  /**
   * This is the panel used for the login screen. It contains all of the
   * components and UI elements necessary for a user to login.
   * 
   * @author Jiminikiz
   */

  private static final long serialVersionUID = 2493040477700737268L;

  private JLabel userLabel = new JLabel("User name:");
  private JLabel passLabel = new JLabel("Password:");

  private JTextField userField = new JTextField(10);

  private JButton loginButton = new JButton("Login");
  private JButton regButton = new JButton("Register");

  public LoginUI(JPasswordField passwordField)
  {
    super();
    this.setFocusable(true);
    
    setLayout(new GridLayout(3, 1));
    userLabel.setForeground(Color.white);
    passLabel.setForeground(Color.white);
    
    add(userLabel);
    add(userField);
    add(passLabel);
    add(passwordField);
    add(loginButton);
    add(regButton);
    setOpaque(false);
  }

  public String getEnteredUserName()
  {
    return userField.getText();
  }

  public void addLoginAction(ActionListener action)
  {
    loginButton.addActionListener(action);
  }

  public void addRegisterAction(ActionListener action)
  {
    regButton.addActionListener(action);
  }
}